--
-- Author: ping.wang
-- Date: 2019-03-06 17:15:50
--
-- PvpDuelTeamView
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)
local PvpDuelPartnerRender = import(".renders.PvpDuelPartnerRender")
local ListViewVertical = require("app.widget.listview.ListViewVertical")
local table_insert = table.insert
ClassRef.VIEW_ROOT_RES = Res.PvpDuelTeamScene

function ClassRef:init()
    self._ui.Button_close:addClickEventListener(function()
        self:closeView()
    end)

    local params = {
        renderClass = PvpDuelPartnerRender,
        perNum = 1,
        cellEventProxy = function(eventName, data)
            if eventName == "changeDuelPartnerStatus" then
                executeFunc(self._onOperate, "changeDuelPartnerStatus", data)
            end
        end,
    }

    self._partnerList = ListViewVertical.new(self._ui.ListView, params)

    --传入随从相关数据 以及 是否上阵信息
    --得到我所拥有的所有随从
    local myDuelVo = self._data.myInfo

    local partner = UD.partnersData:getAlreadyHavePartners()

    local partnerData = {}
    for _,v in ipairs(partner) do
        table_insert(partnerData,{partner = v, isOn = myDuelVo:isPartnerOn(v:getId()), type = self._data.type})
    end

    if #partnerData > 0 then
        self._partnerList:reloadData(partnerData)
    end
end

return ClassRef
